<template>
	<view>
		<u-tabbar v-if="tabbar.length > 0" :value="current" :list="tabbar" :active-color="'#10beca'" :inactive-color="'#6c757d'"
			:mid-button="true" @change="tabChange">
		</u-tabbar>
	</view>
</template>

<script>
	import {
		mapState,
	} from 'vuex';
	export default {
		name:"common-tabbar",
		props:{
			current: {
				type: Number,
				default(){
					return 0
				}
			}
		},
		data() {
			return {
				tabbar: [
					{
						iconPath: "home",
						selectedIconPath: "home-fill",
						text: '首页',
						customIcon: false,
					},
					{
						iconPath: "plus-circle-fill",
						selectedIconPath: "plus-circle-fill",
						text: '回收',
						midButton: true,
						slotMid: true,
						customIcon: false,
					},
					{
						iconPath: "account",
						selectedIconPath: "account-fill",
						text: '我的',
						customIcon: false,
					}
				]
			};
		},
		computed: {
			...mapState({
				userdetail: state => state.userdetail
			})
		},
		methods:{
			tabChange(e) {
				if (e == 0) { //主页atb埋点
					// #ifdef MP-WEIXIN
					// wx.reportEvent("button_tab_home", {
					// 	"type": this.userdetail.type,
					// 	"mobile": this.userdetail.mobile,
					// 	"usename": this.userdetail.name
					// })
					// #endif
					
					uni.switchTab({
						url: '/pages/index/index'
					})
					
				} else if (e == 1) { //回收atb埋点
					// #ifdef MP-WEIXIN
					// wx.reportEvent("recovery", {
					// 	"type": this.userdetail.type,
					// 	"mobile": this.userdetail.mobile,
					// 	"usename": this.userdetail.name
					// })
					// #endif
					
					uni.switchTab({
						url: '/pages/apply/apply'
					})
				} else if (e == 2) { //个人中心埋点
					// #ifdef MP-WEIXIN
					// wx.reportEvent("use_tab", {
					// 	"type": this.userdetail.type,
					// 	"mobile": this.userdetail.mobile,
					// 	"usename": this.userdetail.name
					// })
					// #endif
					
					uni.switchTab({
						url: '/pages/user/user'
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>

</style>